#define _CRT_SECURE_NO_WARNINGS 1

#include"string.h"

namespace F
{
	string::string(const char* str )
	{
		_size = strlen(str);
		_capacity = _size+1;
		_str = new char[_capacity + 1];

		strcpy(_str, str);
	}
	string::string(const string& s)
	{
		string tmp(s._str);
		string::swap(tmp);
	}
	string& string::operator=(const string& s)
	{
		if (this != &s)
		{
			char* tmp = new char[s._capacity + 1];
			strcpy(tmp, s._str);
			delete[] _str;

			_str = tmp;
			_size = s._size;
			_capacity = s._capacity;
		}
		return *this;
	}
	string::~string()
	{
		delete[] _str;
		_str = nullptr;
		_size = 0;
		_capacity = 0;
	}
	void string::swap(string& s)
	{
		std::swap(_str, s._str);
		std::swap(_size, s._size);
		std::swap(_capacity, s._capacity);
	}
	void print_str(const string& s)
	{
		for (size_t i = 0; i < s.size(); i++)
		{
		    //s[i]++;
		    cout << s[i] << " ";
		}
		cout << endl;
	}
}